package socket;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * Created by 5406160@qq.com on LiBoWen 李博闻.
 *
 * @ClassName : InetAddressTest
 * @Author : 54061
 * @Date: 2022/2/25 19:36
 * InetAddress: 此类表示Internet协议(IP)地址
 * 静态方法
 * getByName(String name) : 根据某台电脑的设备名称
 */
public class InetAddressTest {
    public static void main(String[] args) throws UnknownHostException {
        //根据某台电脑的设备名称或ip地址获取对应的InetAddress对象
        InetAddress inetAddress = InetAddress.getByName("LAPTOP");
        //获取指定电脑的设备名称
        System.out.println("设备名称 : " + inetAddress.getHostAddress());
        //获取指定电脑的ip地址
        System.out.println("ip" + inetAddress.getHostAddress());
    }

}
